package com.example.util;

import android.util.Log;

import com.example.inter.AdResultCallBack;
import com.example.inter.AdviceCallBack;
import com.lidroid.xutils.HttpUtils;
import com.lidroid.xutils.exception.HttpException;
import com.lidroid.xutils.http.RequestParams;
import com.lidroid.xutils.http.ResponseInfo;
import com.lidroid.xutils.http.callback.RequestCallBack;
import com.lidroid.xutils.http.client.HttpRequest;

/**
 * Created by zhou on 2016/4/3.
 */
public class SecondAdviceUtil implements AdviceCallBack {
    @Override
    public void getInfo(String ad_id, final AdResultCallBack adResultCallBack) {
        RequestParams params = new RequestParams();
        params.addBodyParameter("ad_id",ad_id);
        Log.i("tttttt",ad_id);
        HttpUtils utils = new HttpUtils();
        utils.send(HttpRequest.HttpMethod.POST,
                "http://192.168.191.1/app/index.php/paperadvice/selectfor", params,
                new RequestCallBack<String>() {
                    @Override
                    public void onLoading(long total, long current, boolean isUploading) {

                    }

                    @Override
                    public void onSuccess(ResponseInfo<String> responseInfo) {

                        adResultCallBack.result(responseInfo.result);

                    }

                    @Override
                    public void onStart() {


                    }

                    @Override
                    public void onFailure(HttpException error, String msg) {
                        //// TODO: 2015/12/18  ∂
                        adResultCallBack.noResult();
                    }


                });


    }
}

